package com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据id查询菜品套餐关联表
     * @param id
     * @return
     */
    @Options(keyProperty ="dishId",useGeneratedKeys = true)
    @Select("select * from sky_take_out.setmeal_dish where dish_id=#{id}")
    SetmealDish findById(Long id);

    /**
     * 新增菜品套餐关联表
     * @param setmealDish
     */
    @Insert("insert into sky_take_out.setmeal_dish values (null, #{setmealId},#{dishId},#{name},#{price},#{copies})")
    void add(SetmealDish setmealDish);

    /**
     *查询套餐菜品关系
     * @param id
     * @return
     */
    @Select("select * from sky_take_out.setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getId(Long id);

    /**
     * 根据id删除套餐菜品关联表
     * @param id
     */
    @Delete("delete from sky_take_out.setmeal_dish where setmeal_id=#{id}")
    void deleteById(Long id);
}
